import React from "react";
import { Card, Paragraph, Text } from "react-native-paper";

interface SuperCardProps {
  url: string;
  title?: string;
  description?: string | React.ReactNode;
  children?: React.ReactNode;
}

export default function SuperCard(props: SuperCardProps) {
  const { description, children } = props;
  const Description = () => {
    if (description !== undefined) {
      if (typeof description === "string") return <Text>{description}</Text>;
      return <>{description}</>;
    }
    return <>{children}</>;
  };
  return (
    <Card elevation={1}>
      <Card.Cover source={{ uri: props.url }} />
      <Card.Content>
        <Paragraph>{props.title}</Paragraph>
        <Description></Description>
      </Card.Content>
    </Card>
  );
}
